package icu.zhhll.datasource.common;

import org.apache.commons.lang3.StringUtils;

/**
 * @author zh
 * @date 2023/10/7 16:46
 */
public class DataSourceHolder {
    private static final ThreadLocal<String> CUR_DATA_SOURCE = new ThreadLocal<>();

    public static String getCurDataSource() {
        return CUR_DATA_SOURCE.get();
    }

    public static void setCurDataSource(String dataSource) {
        if (StringUtils.isNotBlank(dataSource)) {
            CUR_DATA_SOURCE.set(dataSource);
        }
    }

    public static void clearDataSource() {
        CUR_DATA_SOURCE.remove();
    }
}
